package lx3;

import lx2.Saler;

public class Sale implements Runnable{
    private int cnt = 100;

    private static final Object lock = new Object();

    @Override
    public void run() {
        while(true) {
            synchronized (lock) {
                if(cnt == 10)break;
                cnt --;
                System.out.println(Thread.currentThread().getName() +  ":  还剩" + cnt + "个礼物");
                try {
                    Thread.sleep(25);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
